package com.huasoft.servlet.file;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.huasoft.dao.FileDao;
import com.huasoft.domain.File;

public class UpdateFileServlet {

	/**
	 * @param request
	 * @param response
	 * @throws IOException 
	 * @throws ServletException 
	 */
	public void execute(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		File file = new File();
		file.setId(Integer.parseInt(request.getParameter("id")));
		file.setType(request.getParameter("types"));
		file.setTitle(request.getParameter("title"));
		file.setNumber(request.getParameter("numbers"));
		file.setTime(request.getParameter("times"));
		file.setLevel(request.getParameter("levels"));
		FileDao fileDao = new FileDao();
		boolean update = fileDao.update(file);
		if (update) {
			request.setAttribute("msg_updateFileSuccess", "更新案卷成功");
		} else {
			request.setAttribute("msg_updateFileFalse", "更新案卷失败");
		}
		request.getRequestDispatcher("/index.jsp").forward(request, response);
	}

}
